<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新增公示公告</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<%@ include file="/module/orderField.jsp"%>
	<script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
	<link href="${basePath}/css/Huploadify.css" rel="stylesheet">
    <style>
	table label.error {
		margin-left: 5px;
		width: auto;
		display: inline;
		color: red;
	}
	.textat {text-align: center;}
	</style>
		<script type="text/javascript">
        //图片上传
        var file_path = "prefix";
        var file_path_one = null;
        var fileMap = new Array();
        $(function(){
        	var up = $('#uploadadd').Huploadify({
                auto:false,
                fileTypeExts:'*.jpg;*.gif;*.bmp;*.png;*.jpeg',
                multi:false,
                formData:{key:123456,key2:'vvvv'},
                fileSizeLimit:99999999999,
                buttonText:'图片上传',
                // simUploadLimit:1,
                // uploadLimit:1,
                queueSizeLimit:1,
                showUploadedPercent:true,
                showUploadedSize:true,
                removeTimeout:9999999,
                uploader : '${basePath}/partyNotice/source_upload',
                onUploadStart:function(file){
                    console.log(file.name+'开始上传');
                },
                onInit:function(obj){
                    console.log('初始化');
                },
                onUploadComplete:function(file,data){
                    debugger;
                    var fi = $.parseJSON(data);
                    //文件名称
                    var filename = fi.filename;
                    //生成后的文件名
                    var sysFilepath = fi.sysfilepath;
                    //文件路径
                    var filepath = fi.filepath;
                    file_path_one = filename + "," + filepath;
                    file_path = file_path+"|"+filepath;
                    up.filePath=file_path_one;
                    //保存到集合
                    fileMap[file.index]=new Array(file_path_one);
                },
                onCancel:function(file){
                    console.log(file.name+'删除成功');
                },
                onClearQueue:function(queueItemCount){
                    console.log('有'+queueItemCount+'个文件被删除了');
                },
                onDestroy:function(){
                    console.log('destroyed!');
                },
                onSelect:function(file){
                    console.log(file.name+'加入上传队列');
                },
                onQueueComplete:function(queueData){
                    console.log('队列中的文件全部上传完成',queueData);
                    // var _html = $('#uploadadd').innerHTML;
                    // if(_html != '') {
                    //     $('#uploadadd').html('');
                    // }
                },
            });
        });
        //已有的数据进行删除操作
		function deleteByPK(id,filePath){
			var action = "${basePath}/partyNotice/source_upload_update";
		    layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
					$.ajax({
						type : "POST",
						url : action,
						//dataType:"json",
						data:{
							fileId : id,
							filePath : filePath
						},
						success : function(data) {
							if(data.success == "0000"){
								layer.alert('删除数据成功', {icon: 6});
								$("#"+id+"_hr").parent().parent().remove();
							}else{
								layer.alert('未写入数据库的文件没有删除！请联系管理员！', {icon: 5});
							}
						}
					})
			 },function(index){
			    layer.close(index);
		     });
	      }
		 //删除图片
        function deletefile(id){
            var url = "${basePath}/partyInfomation/deletefile";
            $.ajax({
                type : "POST",
                url : url,
                dataType:"json",
                data:{
                    filepath : id
                },
                success : function(data) {
                    if(data.success == "0000"){
                        alert("删除数据成功！");
                        var file_name = id.split(",")[0];
                        $("#"+file_name+"_hr").parent().parent().remove();
                    }else{
                        alert("未写入数据库的文件没有删除！请联系管理员");
                    }
                }
            })
        }
	</script>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post" enctype="multipart/form-data">
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="95%">
			<tr>
				<td class="table-header" colspan="4">公示公告</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%"><font
						style="color: red;">*</font>标题：</td>
				<td class="table-contentTD" colspan="3" style="width: auto;">
					<input id="subject" name="subject"  placeholder="标题"  autocomplete="off" style="width: 80%" maxlength="100" class="inputText required" /></td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%"><font
						style="color: red;">*</font>是否置顶：</td>
				<td class="table-contentTD" style="width: 35%">
				   <input id="onTop_1" type="radio" name="onTop" value="0" checked/>&nbsp;<label for="onTop_1">是</label>
					<input id="onTop_2" type="radio" name="onTop"  value="1"/>&nbsp;<label for="onTop_2">否</label>
				</td>
				<td class="table-titleTD" style="width: 15%"><font style="color: red;">*</font>是否发布：</td>
				<td class="table-contentTD" style="width: 35%">
			      <input id="issued_1" type="radio" name="issued" value="0"  checked/>&nbsp;<label for="issued_1">是</label>
					<input id="issued_2" type="radio" name="issued"  value="1"/>&nbsp;<label for="issued_2">否</label>
			    </td>
			</tr>
			<tr>
			   <td class="table-titleTD" style="width: 15%">图片公告：</td>
				<td class="table-contentTD" colspan="3" style="width: auto;">
				 <input id="isImgLink" type="checkbox" name="isImgLink" value="1" onclick="javascript:show1(this);"/>
			</td>
			</tr>
			<tr id="view" style="display: none;">
			    <td class="table-titleTD" style="width: 15%">图片上传：</td>
				<td class="table-contentTD" colspan="3" style="width: auto;">
				  <table>
						<tr>
							<td colspan="2">
								<%--<div id="uploadadd" ></div>--%>
							    <input type="file" name="file" id="file"/>
                            </td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%">创建人：</td>
				<td class="table-contentTD" style="width: 35%">
				    <input type="hidden" id="creatorId" name="creatorId" value="${user.emid}"/>
					<input type="hidden" id="creatorName" name="creatorName" value="${user.name}"/>
				     ${user.name} 
				</td>
				<td class="table-titleTD" style="width: 15%">创建时间：</td>
				<td class="table-contentTD" style="width: 35%">
				   <input type="hidden" id="createTime" name="createTime" value="${createTime}"/>
					${createTime}
				</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%">正文内容：</td>
				<td class="table-contentTD" colspan="3" style="width: auto;">
					<textarea rows="5" cols="50" name="contents" id="contents" maxlength="500" ></textarea>
				</td>
			</tr>
		</table>
	</form>
	<br />
	<table cellpadding="1" cellspacing="1" border="0" align="left">
	<c:if test="${_login_user_type==2}">
	<tr>
		<td>
		<kl:permission permisstionList="${permisstionList}"
               currentUser="${_login_console_user}"
               currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_DJZX_DJZX\")%>" key="add">
		<input type="button" id="btnSave" class="inputButton textat"  autocomplete="off" value="保存" />
		</kl:permission>
		</td>
		<td>
		<kl:permission permisstionList="${permisstionList}"
               currentUser="${_login_console_user}"
               currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_DJZX_DJZX\")%>" key="add">
		<input type="button" id="btnSaveContinue" class="inputButton textat" autocomplete="off" value="保存并新增" />
		</kl:permission>
		</td>
		<td><input type="button" id="Cancel" class="inputButton textat" autocomplete="off" value="取消" /></td>
		<td><input type="button" id="returnBut" class="inputButton textat" autocomplete="off" value="返回"/></td>
	</tr>
	</c:if>
	</table>
	<script>
	  function show1(_this){
		  if(_this.checked) {
			  $("#view").show();
		  }else {
			  $("#view").hide();
		  }
      } 
		$(document).ready(function() {
			var _form=$("#Form").validate();
			$("#btnSave").click(function() {
				if(_form.form()){
					validataSave();
				}
			});
			$("#btnSaveContinue").click(function() {
				if(_form.form()){
				  	validataSaveContinue();
				}
			});
			function validataSave(){
			   	document.Form.action ="${basePath}/partyNotice/insert?action=1";
				document.Form.submit();
			}
			function validataSaveContinue(){
				document.Form.action ="${basePath}/partyNotice/insert?action=2";
				document.Form.submit();
			}
			$("#returnBut").click(function() {
			   	window.location.href='${basePath}/partyNotice/list';
			});
			$("#Cancel").click(function() {
			   	window.location.href = "${basePath}/partyNotice/add";
			});
		});
	</script>
</body>
</html>